package server;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;

public class Global {
	public static lbs_dao serverDAO = new lbs_dao();
	
	// All logon user clients
	public static HashMap<String, Client> clients = new HashMap<String, Client>();
	
	//String = location
	public static HashMap<String, Group> groups = new HashMap<String, Group>();
	
	// location - gname map
	public static HashMap<String, String> LocGnameMap = new HashMap<String, String>();
	
	// gname - location map
	public static HashMap<String, String> GnameLocMap = new HashMap<String, String>();
	
	//location String
	public static String location = new String ();
	public static String loca_gname = new String ();
	// Sex
	public static final int MALE = 1;
	public static final int FAMALE = 0;
	
	// Group types
	public static final int CLASS = 0;
	public static final int LECTURE = 1;
	public static final int ACTIVITY = 2;
	
	//All type of response
	public static final int RIGHT = 1;
	public static final int WRONG = 2;
	public static final int USERNAMEALREADYEXIST = 3;
	public static final int USERNAMEERR = 4;
	public static final int AUTHORITYERR = 5;
	public static final int RECERIVERNOTLOGON = 6;
	public static final int LOCATIONERR = 7;
	public static final int ALREADYFRIEND = 8;
	public static final int ALREADYLOGON = 9;
	
	public static void init(){
		try {
			String  path ="location.txt";
			location ="";
			loca_gname="";
			BufferedReader in = new BufferedReader(new FileReader(path));
			String ins = null;
			while (null != (ins = in.readLine())){
				System.out.println(ins);
				String af[] = ins.split("\\s+");
				System.out.println(af.length);
				LocGnameMap.put(af[0],af[1]);
				GnameLocMap.put(af[1],af[0]);
				location += ";"+af[0];
				loca_gname+=";"+af[1];
			}
			location=location.substring(1);
			loca_gname=loca_gname.substring(1);
			System.out.println("地理位置列表："+location);
			System.out.println("群组列表："+loca_gname);
			//清空数据库中的记录
			
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
		 catch (IOException e) {
			e.printStackTrace();
		 }
		
	}
	
}
